<?php
include_once ($_SERVER['DOCUMENT_ROOT'].'/global.php');
$array = array();
$BeginTime = $_GET['BeginTime'].' 00:00:00';
$EndTime = $_GET['EndTime'].' 23:59:59';
$sql="SELECT count(1) allnum,count(Status=1 or null) agree,count(Status=2 or null) disagree ,count(Status=0 or null) waitnum,(sum(if(Status=1,Minutes,0)) div 60) hours,(sum(if(Status=1,Minutes,0)) mod 60) Minutes,sum(if(Status=1,Minutes,0))*0.2 allPay  from GongZuoRecord where Isdelete = 0 and str_to_date(BeginTime, '%Y-%m-%d %T') >= str_to_date('{$BeginTime}', '%Y-%m-%d %T') and str_to_date(BeginTime, '%Y-%m-%d %T') <= str_to_date('{$EndTime}', '%Y-%m-%d %T')  ".($_GET['BuMenId'] == '1'?'':"and BuMenId = {$_GET['BuMenId']}");
$query = $mysqli->query($sql);
$array = $query->fetch_assoc();
$array['list'] = array();
$sql = "SELECT b.id,b.XueHao,b.XingMing,count(1) CiShu,sum(Minutes) div 60 hours,sum(Minutes) mod 60 Minutes ,sum(Minutes)*0.2 Pay from GongZuoRecord a,user b where a.IsDelete = 0 and a.person_id = b.id and a.Status = 1  and str_to_date(a.BeginTime, '%Y-%m-%d %T') >= str_to_date('{$BeginTime}', '%Y-%m-%d %T') and str_to_date(a.BeginTime, '%Y-%m-%d %T') <= str_to_date('{$EndTime}', '%Y-%m-%d %T')  ".($_GET['BuMenId'] == '1'?'':"and BuMenId = {$_GET['BuMenId']}")." group by b.id,b.XingMing order by b.XingMing";
$query = $mysqli->query($sql);
while ($a = $query->fetch_assoc()) {
  $array['list'][] = $a;
}
echo json_encode($array);
exit;
?>
